#include <stdio.h>

#include "nuclei_sdk_hal.h"


int main()
{
    printf("test start\r\n");
    /*config SCK CPOL and CPHA*/
    qspi_sckmode_cfg(QSPI0,~(QSPI_SCKMODE_PHA|QSPI_SCKMODE_POL));   // ~��11��=00
    /*disable flashxip mode*/
    qspi_fctrl_flashxip_disable(QSPI0); 
    /*config SCK frequency divider*/
    qspi_sckdiv_cfg(QSPI0,0x01);    // SCK config: f_sck = f_clk / (2*(div+1)) = f_clk / 4;

    printf("QSPI_SCMODE(QSPI0)=0x%x\r\n",QSPI_SCMODE(QSPI0));   // CSMODE = AUTO;
    
    for(int i = 0;i<10;i++)
    {
        qspi_data_transmit(QSPI0,i);;   // TX data
        while(qspi_spi_status(QSPI0));  // check busy or idle
        printf("TXDATA[%d]= %d\r\n",i,QSPI_TXDATA(QSPI0));    // print SPI TX data
    }
    #ifdef CFG_SIMULATION
        pass_fail_simulation(1);
    #endif 
    printf("test finish\r\n");
    while(1);

}